package com.imut.hcdp.controller;

import com.imut.hcdp.common.Rst;
import com.imut.hcdp.domain.HcdpChangYong;
import com.imut.hcdp.domain.HcdpPassenger;
import com.imut.hcdp.mapper.HcdpCyMapper;
import com.imut.hcdp.service.IHcdpPassengerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 常用乘车人
 */
@RestController
@RequestMapping("/system/cy")
public class HcdpCyController
{
    @Autowired
    private HcdpCyMapper hcdpCyMapper;


    @GetMapping("/list")
    public Rst list(HcdpChangYong hcdpChangYong, HttpServletRequest request)
    {
        List<HcdpChangYong> list = hcdpCyMapper.selectByList(hcdpChangYong);
        return Rst.success(list);
    }


    @GetMapping(value = "/{id}")
    public Rst getInfo(@PathVariable("id") Long id)
    {
        return Rst.success(hcdpCyMapper.listById(id));
    }




    @PostMapping
    public Rst add(@RequestBody HcdpChangYong hcdpChangYong)
    {
        return Rst.success(hcdpCyMapper.insert(hcdpChangYong));
    }




    @PutMapping
    public Rst edit(@RequestBody HcdpChangYong hcdpChangYong)
    {
        return Rst.success(hcdpCyMapper.update(hcdpChangYong));
    }




	@DeleteMapping("/{id}")
    public Rst remove(@PathVariable Long id)
    {
        return Rst.success(hcdpCyMapper.deleteById(id));
    }
}
